// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.ooops;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class InlineTestClass {
  private final static int TIMES = 1000000000;
  
  public static void main(String[] args) {
    InlineTestClass testClass = new InlineTestClass();
    
    long time = System.currentTimeMillis();
    System.out.println("Calculated: " + testClass.give(TIMES));
    System.out.println("Time elapsed " + (System.currentTimeMillis() - time) + "ms");
    
    time = System.currentTimeMillis();
    System.out.println("Calculated: " + testClass.give(TIMES));
    System.out.println("Time elapsed " + (System.currentTimeMillis() - time) + "ms");    

    time = System.currentTimeMillis();
    System.out.println("Calculated: " + testClass.give(TIMES));
    System.out.println("Time elapsed " + (System.currentTimeMillis() - time) + "ms");    
  }
  
  public int give(int value) {
    int sum = 0;
    while (value-- != 0) {
      int a = sum;
      a = ((a * 2) + 2) >>> 1;
      sum = a;
    }
    return sum;
  }
  
  @Inline
  private int inc(int a) {
    return ((a * 2) + 2) >>> 1;
  }
}
